package com.gitee.wsl.time.chinese

import kotlin.test.Test
import kotlin.test.assertEquals


/**
 * 干支测试
 */
class GanZhiTest {
    @Test
    fun test() {
        var solar = Solar(2020, 1, 1, 13, 22, 0)
        var lunar = solar.lunar
        assertEquals("己亥", lunar.yearInGanZhi)
        assertEquals("己亥", lunar.yearInGanZhiByLiChun)
        assertEquals("己亥", lunar.yearInGanZhiExact)

        assertEquals("丙子", lunar.monthInGanZhi)
        assertEquals("丙子", lunar.monthInGanZhiExact)


        //小寒
        solar = Solar(2020, 1, 6, 13, 22, 0)
        lunar = solar.lunar
        assertEquals("己亥", lunar.yearInGanZhi)
        assertEquals("己亥", lunar.yearInGanZhiByLiChun)
        assertEquals("己亥", lunar.yearInGanZhiExact)

        assertEquals("丁丑", lunar.monthInGanZhi)
        assertEquals("丁丑", lunar.monthInGanZhiExact)


        solar = Solar(2020, 1, 20, 13, 22, 0)
        lunar = solar.lunar
        assertEquals("己亥", lunar.yearInGanZhi)
        assertEquals("己亥", lunar.yearInGanZhiByLiChun)
        assertEquals("己亥", lunar.yearInGanZhiExact)

        assertEquals("丁丑", lunar.monthInGanZhi)
        assertEquals("丁丑", lunar.monthInGanZhiExact)


        //春节
        solar = Solar(2020, 1, 25, 13, 22, 0)
        lunar = solar.lunar
        assertEquals("庚子", lunar.yearInGanZhi)
        assertEquals("己亥", lunar.yearInGanZhiByLiChun)
        assertEquals("己亥", lunar.yearInGanZhiExact)

        assertEquals("丁丑", lunar.monthInGanZhi)
        assertEquals("丁丑", lunar.monthInGanZhiExact)


        solar = Solar(2020, 1, 30, 13, 22, 0)
        lunar = solar.lunar
        assertEquals("庚子", lunar.yearInGanZhi)
        assertEquals("己亥", lunar.yearInGanZhiByLiChun)
        assertEquals("己亥", lunar.yearInGanZhiExact)

        assertEquals("丁丑", lunar.monthInGanZhi)
        assertEquals("丁丑", lunar.monthInGanZhiExact)


        solar = Solar(2020, 2, 1, 13, 22, 0)
        lunar = solar.lunar
        assertEquals("庚子", lunar.yearInGanZhi)
        assertEquals("己亥", lunar.yearInGanZhiByLiChun)
        assertEquals("己亥", lunar.yearInGanZhiExact)

        assertEquals("丁丑", lunar.monthInGanZhi)
        assertEquals("丁丑", lunar.monthInGanZhiExact)

        solar = Solar(2020, 2, 4, 18, 22, 0)
        lunar = solar.lunar
        assertEquals("庚子", lunar.yearInGanZhi)
        assertEquals("庚子", lunar.yearInGanZhiByLiChun)
        assertEquals("庚子", lunar.yearInGanZhiExact)

        assertEquals("戊寅", lunar.monthInGanZhi)
        assertEquals("戊寅", lunar.monthInGanZhiExact)


        solar = Solar(2020, 2, 5, 13, 22, 0)
        lunar = solar.lunar
        assertEquals("庚子", lunar.yearInGanZhi)
        assertEquals("庚子", lunar.yearInGanZhiByLiChun)
        assertEquals("庚子", lunar.yearInGanZhiExact)

        assertEquals("戊寅", lunar.monthInGanZhi)
        assertEquals("戊寅", lunar.monthInGanZhiExact)


        solar = Solar(2020, 5, 22, 13, 22, 0)
        lunar = solar.lunar
        assertEquals("庚子", lunar.yearInGanZhi)
        assertEquals("庚子", lunar.yearInGanZhiByLiChun)
        assertEquals("庚子", lunar.yearInGanZhiExact)

        assertEquals("辛巳", lunar.monthInGanZhi)
        assertEquals("辛巳", lunar.monthInGanZhiExact)


        solar = Solar(2020, 5, 23, 13, 22, 0)
        lunar = solar.lunar
        assertEquals("庚子", lunar.yearInGanZhi)
        assertEquals("庚子", lunar.yearInGanZhiByLiChun)
        assertEquals("庚子", lunar.yearInGanZhiExact)

        assertEquals("辛巳", lunar.monthInGanZhi)
        assertEquals("辛巳", lunar.monthInGanZhiExact)

        solar = Solar(2020, 5, 29, 13, 22, 0)
        lunar = solar.lunar
        assertEquals("庚子", lunar.yearInGanZhi)
        assertEquals("庚子", lunar.yearInGanZhiByLiChun)
        assertEquals("庚子", lunar.yearInGanZhiExact)

        assertEquals("辛巳", lunar.monthInGanZhi)
        assertEquals("辛巳", lunar.monthInGanZhiExact)

        solar = Solar(2020, 6, 1, 13, 22, 0)
        lunar = solar.lunar
        assertEquals("庚子", lunar.yearInGanZhi)
        assertEquals("庚子", lunar.yearInGanZhiByLiChun)
        assertEquals("庚子", lunar.yearInGanZhiExact)

        assertEquals("辛巳", lunar.monthInGanZhi)
        assertEquals("辛巳", lunar.monthInGanZhiExact)

        solar = Solar(2020, 6, 29, 13, 22, 0)
        lunar = solar.lunar
        assertEquals("庚子", lunar.yearInGanZhi)
        assertEquals("庚子", lunar.yearInGanZhiByLiChun)
        assertEquals("庚子", lunar.yearInGanZhiExact)

        assertEquals("壬午", lunar.monthInGanZhi)
        assertEquals("壬午", lunar.monthInGanZhiExact)

        solar = Solar(2019, 5, 1, 13, 22, 0)
        lunar = solar.lunar
        assertEquals("己亥", lunar.yearInGanZhi)
        assertEquals("己亥", lunar.yearInGanZhiByLiChun)
        assertEquals("己亥", lunar.yearInGanZhiExact)

        assertEquals("戊辰", lunar.monthInGanZhi)
        assertEquals("戊辰", lunar.monthInGanZhiExact)

        solar = Solar(1986, 5, 29, 13, 22, 0)
        lunar = solar.lunar
        assertEquals("丙寅", lunar.yearInGanZhi)
        assertEquals("丙寅", lunar.yearInGanZhiByLiChun)
        assertEquals("丙寅", lunar.yearInGanZhiExact)

        assertEquals("癸巳", lunar.monthInGanZhi)
        assertEquals("癸巳", lunar.monthInGanZhiExact)

        solar = Solar(1986, 5, 1, 1, 22, 0)
        lunar = solar.lunar
        assertEquals("丙寅", lunar.yearInGanZhi)
        assertEquals("丙寅", lunar.yearInGanZhiByLiChun)
        assertEquals("丙寅", lunar.yearInGanZhiExact)

        assertEquals("壬辰", lunar.monthInGanZhi)
        assertEquals("壬辰", lunar.monthInGanZhiExact)

        solar = Solar(1986, 5, 6, 1, 22, 0)
        lunar = solar.lunar
        assertEquals("丙寅", lunar.yearInGanZhi)
        assertEquals("丙寅", lunar.yearInGanZhiByLiChun)
        assertEquals("丙寅", lunar.yearInGanZhiExact)

        assertEquals("癸巳", lunar.monthInGanZhi)
        assertEquals("壬辰", lunar.monthInGanZhiExact)

        solar = Solar(1986, 5, 6, 23, 22, 0)
        lunar = solar.lunar
        assertEquals("丙寅", lunar.yearInGanZhi)
        assertEquals("丙寅", lunar.yearInGanZhiByLiChun)
        assertEquals("丙寅", lunar.yearInGanZhiExact)

        assertEquals("癸巳", lunar.monthInGanZhi)
        assertEquals("癸巳", lunar.monthInGanZhiExact)
    }

    @Test
    fun test1() {
        val solar = Solar(1996, 1, 16)
        val lunar = solar.lunar
        assertEquals("壬子", lunar.dayInGanZhi)
    }

    @Test
    fun test2() {
        val solar = Solar(1997, 2, 16)
        val lunar = solar.lunar
        assertEquals("己丑", lunar.dayInGanZhi)
    }

    @Test
    fun test3() {
        val solar = Solar(1998, 3, 16)
        val lunar = solar.lunar
        assertEquals("壬戌", lunar.dayInGanZhi)
    }

    @Test
    fun test4() {
        val solar = Solar(1999, 4, 16)
        val lunar = solar.lunar
        assertEquals("戊戌", lunar.dayInGanZhi)
    }

    @Test
    fun test5() {
        val solar = Solar(2000, 7, 16)
        val lunar = solar.lunar
        assertEquals("乙亥", lunar.dayInGanZhi)
    }

    @Test
    fun test6() {
        val solar = Solar(2000, 1, 6)
        val lunar = solar.lunar
        assertEquals("癸亥", lunar.dayInGanZhi)
    }

    @Test
    fun test7() {
        val solar = Solar(2000, 1, 9)
        val lunar = solar.lunar
        assertEquals("丙寅", lunar.dayInGanZhi)
    }

    @Test
    fun test8() {
        val solar = Solar(2000, 2, 2)
        val lunar = solar.lunar
        assertEquals("庚寅", lunar.dayInGanZhi)
    }

    @Test
    fun test9() {
        val solar = Solar(2012, 8, 5)
        val lunar = solar.lunar
        assertEquals("戊戌", lunar.dayInGanZhi)
    }

    @Test
    fun test10() {
        val solar = Solar(2012, 9, 20)
        val lunar = solar.lunar
        assertEquals("壬辰", lunar.yearInGanZhi)
        assertEquals("己酉", lunar.monthInGanZhi)
        assertEquals("甲申", lunar.dayInGanZhi)
    }

    @Test
    fun test11() {
        val solar = Solar(2012, 10, 20)
        val lunar = solar.lunar
        assertEquals("壬辰", lunar.yearInGanZhi)
        assertEquals("庚戌", lunar.monthInGanZhi)
        assertEquals("甲寅", lunar.dayInGanZhi)
    }

    @Test
    fun test12() {
        val solar = Solar(2012, 11, 20)
        val lunar = solar.lunar
        assertEquals("壬辰", lunar.yearInGanZhi)
        assertEquals("辛亥", lunar.monthInGanZhi)
        assertEquals("乙酉", lunar.dayInGanZhi)
    }

    @Test
    fun test13() {
        val solar = Solar(2012, 12, 20)
        val lunar = solar.lunar
        assertEquals("壬辰", lunar.yearInGanZhi)
        assertEquals("壬子", lunar.monthInGanZhi)
        assertEquals("乙卯", lunar.dayInGanZhi)
    }

    @Test
    fun test14() {
        val solar = Solar(2012, 12, 27)
        val lunar = solar.lunar
        assertEquals("壬辰", lunar.yearInGanZhi)
        assertEquals("壬子", lunar.monthInGanZhi)
        assertEquals("壬戌", lunar.dayInGanZhi)
    }

    @Test
    fun test15() {
        val solar = Solar(1988, 2, 15)
        val lunar = solar.lunar
        assertEquals("丁卯", lunar.yearInGanZhi)
    }

    @Test
    fun test16() {
        val solar = Solar(1988, 2, 15, 23, 30, 0)
        val lunar = solar.lunar
        assertEquals("丁卯", lunar.yearInGanZhi)
        assertEquals("戊辰", lunar.yearInGanZhiByLiChun)
        assertEquals("戊辰", lunar.yearInGanZhiExact)
    }

    @Test
    fun test17() {
        val solar = Solar(2019, 2, 8, 13, 22, 0)
        val lunar = solar.lunar
        assertEquals("己亥", lunar.yearInGanZhi)
        assertEquals("己亥", lunar.yearInGanZhiByLiChun)
        assertEquals("己亥", lunar.yearInGanZhiExact)

        assertEquals("丙寅", lunar.monthInGanZhi)
        assertEquals("丙寅", lunar.monthInGanZhiExact)
    }

    @Test
    fun test18() {
        val solar = Solar(2020, 2, 4, 13, 22, 0)
        val lunar = solar.lunar
        assertEquals("庚子", lunar.yearInGanZhi)
        assertEquals("庚子", lunar.yearInGanZhiByLiChun)
        assertEquals("己亥", lunar.yearInGanZhiExact)

        assertEquals("戊寅", lunar.monthInGanZhi)
        assertEquals("丁丑", lunar.monthInGanZhiExact)
    }

    @Test
    fun test19() {
        val solar = Solar(2022, 4, 6, 20, 18, 0)
        val lunar = solar.lunar
        assertEquals("壬寅", lunar.yearInGanZhi)
        assertEquals("壬寅", lunar.yearInGanZhiByLiChun)
        assertEquals("壬寅", lunar.yearInGanZhiExact)

        assertEquals("甲辰", lunar.monthInGanZhi)
        assertEquals("甲辰", lunar.monthInGanZhiExact)

        assertEquals("己丑", lunar.dayInGanZhi)
        assertEquals("己丑", lunar.dayInGanZhiExact)
        assertEquals("己丑", lunar.dayInGanZhiExact2)

        assertEquals("甲戌", lunar.timeInGanZhi)
    }
}
